package com.zrrd.fuxi._02_set;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo02
 * @description 比较器
 * @create 2023/11/19 16:02
 */
public class Demo02 {
    /*
    比较器有两种，一个为集合元素类型添加比较器。
    另一个是临时的自定义比较器。




     */
    @Test
    public void studentTest(){
        List<Student> list=new ArrayList<>();
        list.add(new Student(6,"张1111三",15,"男"));
        list.add(new Student(5,"赵六",15,"男"));
        list.add(new Student(4,"王五",15,"男"));
        list.add(new Student(1,"张三",15,"男"));
        list.add(new Student(3,"李四",15,"男"));

        list.forEach(System.out::println);
        Collections.sort(list);
        System.out.println("------------------------------------");
        list.forEach(System.out::println);

    }

}
